﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataEquipAlarmRecord" @search="()=>{getTableDataEquipAlarmRecord();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_EquipAlarmRecord_ProductId')">
            <el-input v-model="searchDataEquipAlarmRecord.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipmentId_FormItem" prop="EquipmentId" :label="$t('message.autotrans._Model_EquipAlarmRecord_Equipment')">
            <el-select v-model="searchDataEquipAlarmRecord.EquipmentId" clearable>
               <el-option v-for="item in stateEquipAlarmRecord.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipCode_FormItem" prop="EquipCode" :label="$t('message.autotrans._Model_EquipAlarmRecord_EquipCode')">
            <el-input v-model="searchDataEquipAlarmRecord.EquipCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipName_FormItem" prop="EquipName" :label="$t('message.autotrans._Model_EquipAlarmRecord_EquipName')">
            <el-input v-model="searchDataEquipAlarmRecord.EquipName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpCode_FormItem" prop="OpCode" :label="$t('message.autotrans._Model_EquipAlarmRecord_OpCode')">
            <el-input v-model="searchDataEquipAlarmRecord.OpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Address_FormItem" prop="Address" :label="$t('message.autotrans._Model_EquipAlarmRecord_Address')">
            <el-input v-model="searchDataEquipAlarmRecord.Address" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Bits_FormItem" prop="Bits" :label="$t('message.autotrans._Model_EquipAlarmRecord_Bits')">
            <el-input v-model="searchDataEquipAlarmRecord.Bits" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Content_FormItem" prop="Content" :label="$t('message.autotrans._Model_EquipAlarmRecord_Content')">
            <el-input v-model="searchDataEquipAlarmRecord.Content" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Level_FormItem" prop="Level" :label="$t('message.autotrans._Model_EquipAlarmRecord_Level')">
            <el-select v-model="searchDataEquipAlarmRecord.Level" clearable>
               <el-option key="L1" value="L1" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L1')"></el-option>
               <el-option key="L2" value="L2" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L2')"></el-option>
               <el-option key="L3" value="L3" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L3')"></el-option>
               <el-option key="L4" value="L4" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L4')"></el-option>
               <el-option key="L5" value="L5" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L5')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Classify_FormItem" prop="Classify" :label="$t('message.autotrans._Model_EquipAlarmRecord_Classify')">
            <el-select v-model="searchDataEquipAlarmRecord.Classify" clearable>
               <el-option key="Robot" value="Robot" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Robot')"></el-option>
               <el-option key="EStop" value="EStop" :label="$t('message.autotrans._Enum_AlarmTypeEnum_EStop')"></el-option>
               <el-option key="SensorOver" value="SensorOver" :label="$t('message.autotrans._Enum_AlarmTypeEnum_SensorOver')"></el-option>
               <el-option key="Cylinder" value="Cylinder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Cylinder')"></el-option>
               <el-option key="Raster" value="Raster" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Raster')"></el-option>
               <el-option key="Welder" value="Welder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welder')"></el-option>
               <el-option key="Servo" value="Servo" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Servo')"></el-option>
               <el-option key="Welding" value="Welding" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welding')"></el-option>
               <el-option key="Vision" value="Vision" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Vision')"></el-option>
               <el-option key="Airtight" value="Airtight" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Airtight')"></el-option>
               <el-option key="General" value="General" :label="$t('message.autotrans._Enum_AlarmTypeEnum_General')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Duration_FormItem" prop="Duration" :label="$t('message.autotrans._Model_EquipAlarmRecord_Duration')">
            <el-input v-model="searchDataEquipAlarmRecord.Duration" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Status_FormItem" prop="Status" :label="$t('message.autotrans._Model_EquipAlarmRecord_Status')">
            <el-select v-model="searchDataEquipAlarmRecord.Status" clearable>
               <el-option key="Doing" value="Doing" :label="$t('message.autotrans._Enum_AlarmStatusEnum_Doing')"></el-option>
               <el-option key="Close" value="Close" :label="$t('message.autotrans._Enum_AlarmStatusEnum_Close')"></el-option>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_AlarmStatusEnum_None')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StartTime_FormItem" prop="StartTime" :label="$t('message.autotrans._Model_EquipAlarmRecord_StartTime')">
            <el-date-picker v-model="searchDataEquipAlarmRecord.StartTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EndTime_FormItem" prop="EndTime" :label="$t('message.autotrans._Model_EquipAlarmRecord_EndTime')">
            <el-date-picker v-model="searchDataEquipAlarmRecord.EndTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/EquipAlarmRecordExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefEquipAlarmRecord" v-bind="tableDataEquipAlarmRecord">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipAlarmRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipAlarmRecordIndex;true;Digitalmes.EquipmentManagement.Controllers;EquipAlarmRecord">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipalarmrecordApi } from '/@/api/equipmentmanagement/equipalarmrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateEquipAlarmRecord = reactive({
    
    AllEquipments: [] as any[],
});

const searchDataEquipAlarmRecord = ref({
        ProductId: null,
        EquipmentId: null,
        EquipCode: '',
        EquipName: '',
        OpCode: '',
        Address: '',
        Bits: null,
        Content: '',
        Level: undefined,
        Classify: undefined,
        Duration: null,
        Status: undefined,
        StartTime: undefined,
        EndTime: undefined,
});

// 定义变量内容
const tableRefEquipAlarmRecord = ref();
const tableDataEquipAlarmRecord = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page产品号'),key: 'EquipAlarmRecord_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备'),key: 'EquipAlarmRecord_Equipment',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备编号'),key: 'EquipAlarmRecord_EquipCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备名称'),key: 'EquipAlarmRecord_EquipName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位'),key: 'EquipAlarmRecord_OpCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警地址'),key: 'EquipAlarmRecord_Address',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page位'),key: 'EquipAlarmRecord_Bits',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警内容'),key: 'EquipAlarmRecord_Content',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警级别'),key: 'EquipAlarmRecord_Level',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警分类'),key: 'EquipAlarmRecord_Classify',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page警报时长'),key: 'EquipAlarmRecord_Duration',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警状态'),key: 'EquipAlarmRecord_Status',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page开始时间'),key: 'EquipAlarmRecord_StartTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page结束时间'),key: 'EquipAlarmRecord_EndTime',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataEquipAlarmRecord = () => {
    tableRefEquipAlarmRecord.value.doSearch(equipalarmrecordApi().search, searchDataEquipAlarmRecord.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataEquipAlarmRecord)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataEquipAlarmRecord)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataEquipAlarmRecord)
};

// 删除
const onDelete = (row: any) => {
    equipalarmrecordApi().delete([row.ID]).then(() => { getTableDataEquipAlarmRecord()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefEquipAlarmRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      equipalarmrecordApi().delete(selectedids).then(() => { getTableDataEquipAlarmRecord()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefEquipAlarmRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataEquipAlarmRecord)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataEquipAlarmRecord)
};

const onExport = () => {
	const selected = tableRefEquipAlarmRecord.value.getSelectedRows();
	if (selected.length > 0) {
		equipalarmrecordApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		equipalarmrecordApi().export(searchDataEquipAlarmRecord.value);
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipAlarmRecord/GetEquipments',[],false).then(x=>{stateEquipAlarmRecord.AllEquipments = x});
        getTableDataEquipAlarmRecord();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

